# Contributor: tcely <tcely@users.noreply.github.com>
# Maintainer:
pkgname="fstrm"
pkgver="0.6.0"
pkgrel=1
pkgdesc="Frame Streams implementation in C"
url="https://github.com/farsightsec/fstrm"
arch="all"
# check failure on s390x reported upstream:
#    https://github.com/farsightsec/fstrm/issues/58
license="MIT"
checkdepends="findutils"
makedepends="libevent-dev"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-utils"
source="https://dl.farsightsecurity.com/dist/fstrm/fstrm-$pkgver.tar.gz
	reduce-testruns.patch"

build() {
	cd "$builddir"

	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man
	make
}

_cat_found_file() {
	local _rc="$?"
	find -name "$1" -type f -ls -printf '%P {{{\n' -exec cat -v -n '{}' ';' -printf '}}} %P\n'
	return "$_rc"
}

check() {
	cd "$builddir"

	make check || _cat_found_file 'test-suite.log'
}

package() {
	cd "$builddir"

	make -j1 DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="$pkgname utilities"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/* "$subpkgdir"/usr/bin/
}

sha512sums="d1b754caadb1bd8b4b4ce3e7394168dd0a20353e0b7ac65f28d016d840aefe6fa1ab1aa778564e775152164855b38a47ab5817866f8bfb0b2d70520b2881225d  fstrm-0.6.0.tar.gz
1c687ee7741fb20a571c3d7d3fb9a1cf09709d83d66d788eb09835750ee2313aa565f74d35a9cdece2154e1b8c41c68b268ca8f5bc33f8d14550ebe46880d550  reduce-testruns.patch"
